package com.apes.crm.car.model;


import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarBusiness.CONST_TABLE_NAME, indexes = {@Index(name = "idx_crm_car_business", columnList = "CAR_ID", unique = true)})
public class CarBusiness extends Model {
    public static final String CONST_TABLE_NAME = "crm_car_business";

    @Id
    @Column(name = "id", nullable = false, length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车辆商务信息", padding = 8)
    private String id; // id

    @OneToOne(optional = false)
    @JoinColumn(name = "car_id",referencedColumnName = "id")
    private CarBase car; // 车辆id

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "annual_review_date")
    private Date annualReviewDate; // 年审日期

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "annual_review_result",referencedColumnName = "id")
    private Enumeration annualReviewResult; // 年审结果 (0:不合格;1:合格)

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "tail_gas_Qualified",referencedColumnName = "id")
    private Enumeration tailGasQualified; // 环保达标情况 (0:不合格;1:合格)(尾气合格)

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "next_visit_date")
    private Date nextVisitDate; // 下次年审回访时间



}
